package com.sky.controller.admin;

import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.SetmealVO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @projectName: HF62sky
 * @package: com.sky.controller.admin
 * @className: SetmealController
 * @author: SunGang
 * @description: TODO
 * @date: 2023/12/6 11:10
 * @version: 1.0
 */
@RestController
@RequestMapping("/admin/setmeal")
@RequiredArgsConstructor
public class SetmealController {
    private final SetmealService setmealService;
    @PostMapping
    public Result<?> add(@RequestBody SetmealDTO setmealDTO){
        setmealService.add(setmealDTO);
        return  Result.success();
    }
    @GetMapping("/page")
    public Result<PageResult> queryByPage(SetmealPageQueryDTO setmealPageQueryDTO){
     PageResult pageResult= setmealService.queryByPage(setmealPageQueryDTO);
        return  Result.success(pageResult);
    }
    @PostMapping("/status/{status}")
    public Result<?> modifyStatus(@PathVariable Integer status,Long id){
      setmealService.modifyStatus(status,id);
      return Result.success();
    }
    @DeleteMapping
    public Result<?> delete(@RequestParam List<String> ids){
        setmealService.deleteSetmeal(ids);
        return Result.success();
    }

    @GetMapping("/{id}")
    public Result< SetmealVO> findById(@PathVariable Long id){
      SetmealVO setmealVO=setmealService.findById(id);
      return Result.success(setmealVO);
    }
    @PutMapping
    public Result<?> modify(@RequestBody SetmealDTO setmealDTO){
        setmealService.modifySetmeal(setmealDTO);
        return Result.success();
    }
}
